﻿using Sl.Upload.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sl.Upload.Models;

namespace Sl.Upload.FileTest
{
    public class StoragePath : IStoragePath
    {
        public FilePath GetPath(PostFileParam pfp)
        {
            string time = DateTime.Now.ToString("yyyy-MM-dd");
            FilePath fp = new FilePath();
            fp.SavePath = System.Web.HttpContext.Current.Request.PhysicalApplicationPath + "Upload\\" + pfp.Id + GetPathUpload(pfp.UploadPathType) + "Org\\" + time;
            fp.UrlPath = "/Upload/" + pfp.Id + GetPathUpload(pfp.UploadPathType).Replace("\\", "/") + "Org/" + time;
            return fp;
        }

        public string GetPathUpload(string type)
        {
            if (type == "dynamic")
                return "\\dynamic\\";
            else if (type == "avatar")
                return "\\avatar\\";
            return "\\Info\\";
        }
    }
}